Skip to content

Replication streaming compression (per-replica) - review vs #3531 base - #21

Open
roshkhatri wants to merge 1 commit into
streaming-compression-rio-prfrom
replication-streaming-compression-v2
Open

Replication streaming compression (per-replica) - review vs #3531 base#21
roshkhatri wants to merge 1 commit into
streaming-compression-rio-prfrom
replication-streaming-compression-v2

Conversation

@roshkhatri

Copy link
Copy Markdown
Owner

Review-only PR: isolates the per-replica replication-stream compression work, squashed to one commit on sarthak's latest valkey-io#3531 base (3975e1a, post compression-layer refactor).

  • Base: streaming-compression-rio-pr @ 3975e1a
  • Head: replication-streaming-compression-v2 (single commit: Streaming Compression support for replication stream)

Supersedes #19 (old base lineage). Does not update the upstream PR.

@roshkhatri
roshkhatri force-pushed the replication-streaming-compression-v2 branch 4 times, most recently from 2f851c3 to 3688b40 Compare July 29, 2026 23:07
Comment thread .github/workflows/ci.yml Outdated
Comment on lines +201 to +216
# Re-runs the replication suite with repl-compression=lz4-stream applied
# globally via --config. Test files opt in by carrying the top-level "repl-compression"
# tag (see tests/support/server.tcl), so this job selects them with
# --tags repl-compression instead of a hardcoded filename list that would
# silently drift if a file is renamed. Exercises the streaming-compression
# transport across the replication surface (full sync, dual-channel, buffer
# management, AOF-sync, etc.) to catch regressions that only surface under
# compressed replication.
# Note: a few tests are intentionally NOT tagged for this job:
# - integration/replication-psync: its start_server lives inside a reusable
# proc, incompatible with a top-level-only tag.
# - integration/replication-buffer.tcl and the buffer-memory tests in
# integration/dual-channel-replication.tcl: they assert exact replication
# buffer/backlog memory and byte volumes, which compression legitimately
# changes (per-replica codec buffers, fewer wire bytes). They run in the
# regular (uncompressed) job.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be shortned

Comment thread src/compression_stream.c Outdated
return 0;
}

/* Sink path: compress directly into the caller's sds tail, no scratch/emit. */

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove , no scratch/emit.

Comment thread src/config.c Outdated

/* Set by the repl-compression apply callback when the setting changes. Switching
* a live link between plaintext and compressed requires a reconnect, which is
* irreversible, so the reconcile is deferred until after the whole CONFIG SET

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shorten this

Comment thread src/config.c Outdated
/* Switching existing replicas between plaintext and compressed requires a
* reconnect, which is irreversible. Only record intent here; configSetCommand
* runs the reconcile after the command commits, so a rolled-back CONFIG SET
* disconnects nothing. */

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shorten this

Comment thread src/io_threads.c Outdated
/* Primary client with a live replication decoder (probing or compressed)
* must be decoded on the main thread; the IO-thread read path does not
* invoke replDecompressQueryBuf. Once the probe resolves to plaintext the
* decoder is destroyed and reads return here. */

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shorten this

Comment thread src/networking.c Outdated
/* Check for unsent compressed data in the compressed output buffer.
* Skip while CLIENT_PENDING_IO: the IO thread owns out_buf and may
* realloc it, so the main thread must not read it here
* (postWriteToReplica re-checks once the write job completes). */

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shorten this

Comment thread src/networking.c Outdated
* malicious or buggy primary; disconnect rather than allocate unbounded. */
#define REPL_STREAM_DECODER_OUTPUT_MAX (256 * 1024 * 1024)

int replDecompressQueryBuf(client *c, size_t new_data_start) {

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this belong to some replication file?

Comment thread src/replication.c Outdated
Comment on lines +89 to +99

/* Reconcile each replica's transport with the current repl-compression setting
* after a runtime change. A live link cannot switch between plaintext and a
* compressed VCS/LZ4 frame mid-stream, so a mismatched replica is dropped and
* reconnects to renegotiate:
* - compression disabled: drop replicas still on a compressed stream;
* - compression enabled: drop online replicas that advertised the capability
* but are still plaintext, so they come back compressed.
* Disconnect is async because we run inside the main event loop; the iteration
* is safe since freeClientAsync does not remove from server.replicas
* synchronously. Replicas still syncing are left alone: they pick up the current

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shorten this

Comment thread src/replication.c Outdated
Comment on lines +131 to +134
/* If we are ourselves a replica, the compression capability was negotiated
* with our primary at handshake time. A config change must renegotiate, so
* drop the upstream link; the replication cron reconnects and re-advertises
* capa with the new setting. */

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shorten this

@roshkhatri
roshkhatri force-pushed the replication-streaming-compression-v2 branch 2 times, most recently from beaa970 to 5d2009b Compare July 30, 2026 07:52
Signed-off-by: Roshan Khatri <rvkhatri@amazon.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant